package com.best.adapter;

import java.util.List;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;

public class ViewPagerAdapter  extends PagerAdapter{
	private Context mContext;
	private List<View> viewList;
	public ViewPagerAdapter(Context mContext,List<View> viewList){
		this.mContext = mContext;
		this.viewList = viewList;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return viewList.size();
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		// TODO Auto-generated method stub
		return arg0 == arg1;
	}
	@Override
	public void destroyItem(View container, int position, Object object) {
		// TODO Auto-generated method stub
		//super.destroyItem(container, position, object);
		((ViewPager) container).removeView(viewList.get(position));
	}
	@Override
	public Object instantiateItem(View container, int position) {
		// TODO Auto-generated method stub
		//return super.instantiateItem(container, position);
		View v = viewList.get(position);
		((ViewGroup) container).addView(v,0);
		return v;
	}

}
